<?php
/*
	数据清理
	清理所有数据
	清理日志数据
	
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?:'set';
if($_RQ['op']=='set'){
	if($_RQ['postdata']){
		$post=get_postdata();
		
		if($post['depot']){
			
			$depots=$this->pdo_getall('depot',array('uniacid'=>$_SESSION['uniacid']),array('id'));
			if($depots){
				foreach($depots as $depot){
					$this->model('depot')->del_depot($depot['id']);
				}
			}
		}
		if($post['goods']){
			$tables=array('goods');
			foreach($tables as $table){
				$this->pdo_delete($table,array('uniacid'=>$_SESSION['uniacid']));
			}
			
		}
		exi('清理成功！','','set');
	}
	$return['item']=array();
	$return['htmls']=array(
		'type'=>'edit',
		'desc'=>'设置要清理哪些数据',
		'edit'=>array(
			array('type'=>'switch','name'=>'depot','title'=>'仓库数据','help'=>'启用后，仓库，仓库商品，出入库日志等仓库信息将全部清空'),
			array('type'=>'switch','name'=>'goods','title'=>'商品数据','help'=>'启用后，商品数据将被清空'),
			//array('type'=>'switch','name'=>'all','title'=>'所有数据','help'=>'启用后，本应用所有数据都将被清空！'),
		),
	);
	exi($return);
}